<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>取消时间器</title>
</head>

<body>
    <button id="start">开始</button>
    <button id="stop">结束</button>
</body>
<script>
    // let timer = setInterval(): 定时器    clearInterval(timer) 清除定时器
    // let timer2 = setTimeout(): 延时器    clearTimeout(timer2) 清除延时器

    let startbtnEle = document.getElementById("start");
    let stopbtnEle = document.getElementById("stop");
    let timer;
    startbtnEle.addEventListener("click", function () {
        this.disabled = true;
        timer = setInterval(function () {
            console.log('心脏撒撒给哟');
        });
    },1000);
    stopbtnEle.addEventListener("click", function () {
        startbtnEle.disabled = false;
        clearInterval(timer);
    })
</script>

</html>